﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HFK.DxFluentUI.Utility;
using HFK.DxFluentUITest.Dummy.DataObjects;
using MbUnit.Framework;

namespace HFK.DxFluentUITest.Utility
{
  [TestFixture]
  public class ChildPropertySyntaxTestFixture
  {
    [Test]
    public void TestZeroHop()
    {
      ChildPropertySyntax syntax = new ChildPropertySyntax("Value");

      Assert.AreEqual(1, syntax.Count);
      Assert.AreEqual("Value", syntax.Property(0));
    }

    [Test]
    public void TestDualHop()
    {
      ChildPropertySyntax syntax = new ChildPropertySyntax("Value.Hop1.Hop2");

      Assert.AreEqual(3, syntax.Count);
      Assert.AreEqual("Value", syntax.Property(0));
      Assert.AreEqual("Value", syntax.PropertyUntil(0));
      Assert.AreEqual("Hop1", syntax.Property(1));
      Assert.AreEqual("Value.Hop1", syntax.PropertyUntil(1));
      Assert.AreEqual("Hop2", syntax.Property(2));
      Assert.AreEqual("Value.Hop1.Hop2", syntax.PropertyUntil(2));
    }

    [Test]
    public void TestCreationZeroHop()
    {
      ChildPropertySyntax syntax = ChildPropertySyntax.Create<SimpleClass, int>(x => x.IntValue);

      Assert.AreEqual("IntValue", syntax.PropertyName);
    }

    [Test]
    public void TestCreationSingleHop()
    {
      ChildPropertySyntax syntax = ChildPropertySyntax.Create<SimpleClass, string>(x => x.ShcData.StringValue);

      Assert.AreEqual("ShcData.StringValue", syntax.PropertyName);
    }

    [Test]
    public void TestCreationTripleHop()
    {
      ChildPropertySyntax syntax = ChildPropertySyntax.Create<SimpleClass, string>(x => x.ShcData.DhcProperty.ThcProperty.StringProperty);

      Assert.AreEqual("ShcData.DhcProperty.ThcProperty.StringProperty", syntax.PropertyName);
    }
  }
}
